/**
 * This class represent's the player's spaceship, and tracks name, health, shields, cargo, etc.
 * @author Stanley Ayzenberg, Michelle Partogi, Adam Perez, Araya Zaesim
 * @version 1.0
 */

public class SpaceShip {

	private String name;
	private int health;
	private int shields;
	private int speed;
	private int[] goods;
	private int maxCarg;
	private int currentCarg;
	private int fuel;
	private int maxFuel;
	private int maxDistance;
	public SpaceShip(String shipName, int[] def) {
		if (shipName == "Gnat") {
			name = "Gnat";
			health = 100;
			shields = 0;
			goods = def;
			maxCarg = 15;
			maxFuel = 10;
			fuel = 10;
			currentCarg = 0;
			maxDistance = 30;
		}
	}
	
	public int getMaxDistance() {
		return maxDistance;
	}

	public void setMaxDistance(int maxDistance) {
		this.maxDistance = maxDistance;
	}

	/**
	 * Returns the goods in the spaceship
	 * @return The goods in the spaceship
	 */
	public int[] getGoods() {
		return goods;
	}
	/**
	 * Sets the goods in the spaceship
	 * @param newGoods The goods in the spaceship
	 */
	public void setGoods(int[] newGoods) {
		goods = newGoods;
	}
	
	/**
	 * Returns whether or not the ship is full of cargo
	 * @return Whether or not the ship is full of cargo
	 */
	public boolean isFull() {
		return maxCarg == currentCarg;
	}
	
	/**
	 * Returns the amount of cargo in the ship
	 * @return The amount of cargo in the ship
	 */
	public int getCargo() {
		return currentCarg;
	}
	
	/**
	 * Sets the amount of cargo in the ship
	 * @param n The amount of cargo in the ship
	 */
	public void setCargo(int n) {
		currentCarg = n;
	}
	
	/**
	 * Sets the amount of fuel in the ship
	 * @param fuel Amount of fuel in the ship
	 */
	public void setFuel(int fuel) {
		this.fuel = fuel;
	}
	
	/**
	 * Returns the amount of fuel in the ship
	 * @return Amount of fuel in the ship
	 */
	public int getFuel() {
		return fuel;
	}
	
	/**
	 * Returns the maximum amount of fuel in the ship
	 * @return Maximum amount of fuel in the ship
	 */
	public int getMaxFuel() {
		return maxFuel;
	}
	
	/**
	 * Returns the maximum cargo spaces in the current spaceship
	 * @return Maximum number of cargo spaces
	 */
	public int getMaxCargo() {
		return maxCarg;
	}
	
	public void updateFuelFromTravel(SolarSystem current, SolarSystem target, Player p) {
    	double fuelEfficiency = (maxDistance + (p.getPilotPoints()/1.5)) / maxFuel;
    	double distance = target.getDistance(current);
    	fuel = fuel - (int)(distance/fuelEfficiency);
	}
}
